from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta

def start_scheduler(task_func, interval_hours=1, *args, **kwargs):
    scheduler = BackgroundScheduler(timezone="Asia/Shanghai")
    scheduler.add_job(
        task_func,
        'interval',
        hours=interval_hours,
        args=args,
        kwargs=kwargs
    )
    scheduler.start()
    print(f"调度器已启动，每{interval_hours}小时执行一次任务。")
    return scheduler 